Repository navigation
Combat 2.1c: Let a damage request scale or add to the weapon's damage - #193
Merged
Merged
Conversation
A request can now say that the attacker's weapon damage takes part in the hit changed: multiplied by a factor, with an amount added, for every damage type or for one. Divinity's damage action and area damage are weapon swings of that kind, and a skill that deals a share of the weapon's damage is too. Additive. A request that sets none of this leaves the weapon's damage as it is. Part of magemonkeystudio/divinity#365 Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FaEyTtryHphQWR4EVUMbsz
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of magemonkeystudio/divinity#365. Needed by Combat 2.2 (magemonkeystudio/divinity#370).
Why
A
DamageRequestcould say "add these amounts to the weapon's damage" or "use only these amounts". Two of Divinity's own dealers are neither: the damage action and area damage are full weapon swings with every damage type changed, by a flat amount or a percentage. Today they do that by temporarily editing the attacker's stats before dealing 1 damage, which can leak into the attacker's next swing (see magemonkeystudio/divinity#381).A skill that deals "150% weapon damage" is the same shape, so this is useful to Fabled as well.
What is added
On
DamageRequest.builder():weaponScale(factor)weaponScale(type, factor)weaponBonus(amount)weaponBonus(type, amount)On
DamageRequest:adjustWeaponDamage(type, amount)amount * scale + bonusgetWeaponScale(type),getWeaponBonus(type)getWeaponScale(),getWeaponBonus()adjustsWeaponDamage()Rules
ADDmode, where the weapon's damage is part of the hit. Codex carries the values in any mode and does not enforce that.fire, notDIVINITY_fire), because they name the weapon's damage types, not a classification to be routed.The arithmetic gives the same floating-point results as Divinity's current operators:
d * 1 + bonusequalsd + bonus, andd * scale + 0equalsd * scale.Must not change
A request that sets none of this behaves exactly as before. Nothing else is touched.
Tests
mvn -DskipNms -pl codex-api,codex-core -am test, exit code 0. 8 new tests inDamageRequestTest, 0 failures, 0 skipped.Break-it checks, one edit at a time, each restored. All were caught:
weaponBonus_doesNotGiveAWeaponADamageTypeItDoesNotDealweaponScaleAndBonus_scaleFirstThenAddand one moreweaponScaleAndBonus_forOneType_replaceTheOnesForEveryTypeadjustsWeaponDamageignores per-type valuesweaponScaleForOneTypeOnly_countsAsAnAdjustmentGenerated by Claude Code